import { $get, $post } from "./index";

// 待确认列表查询
export interface WorkerOrderOrderListParam {
  btcId: string;
  work: boolean;
  keywords: string;
  wxStatus?: number;
  pickUpMode?: number;
  examineFlag?: boolean;
  record?: boolean;
  startBillingTime?: string;
  endBillingTime?: string;
}

export interface Page {
  pageSize: number;
  pageNum: number;
}

export const waitForConfirm = (page: Page, data: WorkerOrderOrderListParam) => {
  return $post(
    `/selfmachine-system/workerIndex/listNew?pageSize=${page.pageSize}&pageNum=${page.pageNum}`,
    data
  );
};

// 取消订单
export interface cancelOrderParams {
  ssoId: string; // 订单编号
}

export const cancelOrder = (data: cancelOrderParams) => {
  return $post("/selfmachine-system/workerOrder/cancelOrder", data);
};

// 常用货物名称，类型，包装
export interface ssopSignParams {
  ssopSign: string | number; // 1货物名称 2货物类型 3货物包装
  ssopRemark: string; // 搜索
}
export const getNameGoods = (data: ssopSignParams) => {
  return $post("/selfmachine-system/workerIndex/nameGoods", data);
};

// 查询库位
export interface warehouseParams {
  companyNo: string | number; // 网点编号
  send: boolean; // 默认
  keyWord: string; // 关键词
}
export const getWarehouse = (data: warehouseParams) => {
  return $get("/selfmachine-system/workerIndex/warehouseNew", data);
};

// 查询确认订单信息
export const getList = (data) => {
  return $post("/selfmachine-system/order/list?pageNum", data);
};

// 查询省市区联动
export const getAddressByCode = (data) => {
  return $post("http://it.shenghui56.com/serversh/general/addressByCode", data);
};

// 查询签单单位列表
export interface signUnitParams {
  branchCompanyNo: string | number;
  keyWord: string; // 关键词
}
export const getSignUnit = (data: signUnitParams) => {
  return $get("/selfmachine-system/order/getSignUnit", data);
};

// 查询接开单员列表
export interface btStaffInfoParams {
  branchCompanyNo: string | number; // 网点编号
  keyWord: string; // 关键词
}
export const getBtStaffInfo = (data: btStaffInfoParams) => {
  return $get("/selfmachine-system/user/queryBtStaffInfo", data);
};

// 获取openid
export interface openIdParams {
  code: string; // code
}
export const getOpenId = (data: openIdParams) => {
  return $get(`/selfmachine-system/workerIndex/getOpenId?${data.code}`);
};

// 查询银行卡列表
export const getBankList = () => {
  return $post("/selfmachine-system/banks/list", {});
};

// 查询接货费
export interface takeFeeParams {
  branch: string | number;
  destination: string;
  excess: boolean;
  firs: boolean;
  numbers: number;
  orderId: string;
  preorderid: string;
  source: string;
  volume: string | number;
  weight: string | number;
}
export const getTakeFee = (data) => {
  return $post("/selfmachine-system/fee/calcCargoPriceNew", data);
};

// 查询长途运费
export const getLongPriceFee = (data) => {
  return $post("/selfmachine-system/order/longPrice", data);
};

// 查询送货费
export const getSendGoodsFee = (data) => {
  return $post("/selfmachine-system/fee/calcDeliveryPrice", data);
};

// 判断是否代收货款
// export const getPaymentToggle = (keywords) => {
//   return $get(`/selfmachine-system/branch/loadCompanyTree?keywords=${keywords}`);
// };

// 判断是否代收货款（用这个）
export const getPaymentToggle = (branchCompanyNo) => {
  return $get(`/selfmachine-system/branch/particulars?branchCompanyNo=${branchCompanyNo}`);
};


// 查询开户行列表
export const getBankNameList = (keywords) => {
  return $get(`/selfmachine-system/branch/loadCompanyTree?keywords=${keywords}`);
};

// 查询网点列表地点/电话
export const getBranchList = (keywords) => {
  return $get(`/selfmachine-system/branch/loadCompanyTree?keywords=${keywords}`);
};

// 查询推荐网点
export const getReturnForm = (params) => {
  return $get(`http://192.168.10.32:85/assign/map/returnForm?address=${params.destinationAddress}&did=${params.destinationBranch}&carriageType=1&ISShipForMe=0`);
};

// 计算距离拿到推荐网点的电话
export const queryDistance = (data) => {
  return $post(`/selfmachine-system/branch/queryDistance`,data);
};

// 查询银行卡号列表
export const getBankCard = (data) => {
  return $post(`/system/addressBook/getAccountDetails`,data);
};

// 查询目的地选点列表
export const loadCompanyTree = (keywords) => {
  return $get(`/selfmachine-system/branch/loadCompanyTree?keywords=${keywords}`);
};


// 查询其它费用承运类型
export const getFeeType = (ssopSign) => {
  return $get(`/selfmachine-system/order/publicInfo?ssopSign=${ssopSign}`);
};

//确认运单接口
export const sureOrder = (data) => {
  return $post(`/selfmachine-system/workerOrder/workerOrderConfirm`,data);
};


// 判断承运类型是否可选
export const checkSendType = (data) => {
  return $post(`/selfmachine-system/btBaseBusiness/checkBusiness`,data);
};